fix: EMRTEXT wire layout — ptlReference is POINTL not WmfRect16 - #6
Merged
Conversation
After studying libemf2svg's emf2svg_rec_drawing.c and the U_EMRTEXT struct in libUEMF, discovered the wire layout was wrong. Previous (incorrect): int16 wmf_rect_left/top/right/bottom (WmfRect16, 8 bytes) Correct (per MS-EMF 2.2.6 EMRTEXT): point_l ptl_reference (POINTL, 8 bytes — int32 x, int32 y) uint32 n_chars uint32 off_string uint32 f_options rectl rcl (RECTL, 16 bytes — clipping rectangle) uint32 off_dx The ptlReference is the text anchor point — the most critical field for text positioning. Was previously parsed as 4 int16 values (wmf_rect_left/top/right/bottom) which mapped to the wrong bytes, causing all text to be positioned at incorrect coordinates. Round-trip verified: 208/208 byte-identical.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Critical wire layout fix discovered by studying libemf2svg's U_EMRTEXT struct definition. ptlReference (POINTL: two int32) was being parsed as WmfRect16 (four int16). Text positions were completely wrong.
Companion to emfsvg PR that takes advantage of this fix to reach 81.1% byte ratio vs libemf2svg.
Round-trip: 208/208 byte-identical.